import request from '@/utils/request'


// 新增登记
export function checkContractNo(contractNo) {
  console.log(contractNo)
  return request({
    url: '/business/business/checkContractNo',
    method: 'get',
    params: { contractNo } // 将 contractNo 放在一个对象中, 以确保参数名称一致
  })
}

// 查询列表
export function getListLb(query){
  return request({
    url: '/check/type/list',
    method: 'get',
    params: query
  })
}
// 查询检测项目
export function getListXm(query){
  return request({
    url: '/check/item/list',
    method: 'get',
    params: query
  })
}

export function selectDetectionCategory(detectionCategory,type) {
  console.log(detectionCategory)
  return request({
    url: '/business/business/selectDetectionCategory',
    method: 'get',
    params: { detectionCategory,type } // 将 contractNo 放在一个对象中, 以确保参数名称一致
  })
}
// 根据id查找抄送人
export function selectUserByDeptId(DeptId) {
  return request({
    url: '/business/business/selectUserByDeptId',
    method: 'get',
    params: { DeptId } // 将 contractNo 放在一个对象中, 以确保参数名称一致
  })
}

// 查找部门
export function selectDeptTree(type) {
  console.log("DeptTree")
  return request({
    url: '/business/business/selectDeptTree',
    method: 'get',
    params: { type }
  })
}

// 查找部门
export function selectTestItems(taskId) {
  console.log("selectTestItems")
  return request({
    url: '/business/business/selectTestItems',
    method: 'get',
    params: { taskId }
  })
}

//部门对应ccid
export function selectCcName(currentDept) {
  if(currentDept == '质控室'){//任务单审核
    return 1;
  }else if (currentDept == '检测室'){//采样检测业务
    return 2;
  }
  else if (currentDept == '市场部'){//首页提醒
    return 8;
  }
  else if (currentDept == '报告室'){//检测报告
    return 5;
  }
  else if (currentDept == '化验室'){//样品管理与实验分析
    return 4;
  }else {//运营部 没有提醒
    return 0;
  } 
  
}


// 删除
export function delContract(taskId) {
  return request({
    url: '/business/business/' + taskId,
    method: 'delete'
  })
}

// 提交操作
export function samplingUploadSubmit(taskId) {
  return request({
    url: '/business/business/samplingUploadSubmit',
    method: 'get',
    params: { taskId } 
  })
}

// 删除
export function killContract(taskId) {
  return request({
    url: '/business/business/kill' + taskId,
    method: 'delete'
  })
}

// 退回
export function requestSubscribeMessage(OpenId) {
  return request({
    url: '/business/business/requestSubscribeMessage',
    method: 'post',
	params: { OpenId }
  })
}
// 退回
export function rejectTask(data) {
  return request({
    url: '/business/business/rejectTask',
    method: 'post',
    data: data
  })
}
// 退回
export function receiveTask(data) {
  return request({
    url: '/business/business/receiveTask',
    method: 'post',
    data: data
  })
}


// 新增登记
export function add(data) {
  return request({
    url: '/business/business/add',
    method: 'post',
    data: data
  })
}


// 抄送后台请求
export function toExamine(data) {
  return request({
    url: '/business/business/toExamine',
    method: 'post',
    data: data
  })
}
  
// 获取task的文件详情
export function getTaskFiles(data) {
  return request({
    url: '/business/business/getTaskFiles',
    method: 'post',
    data: data
  })
}

// 修改登记
export function update(data) {
  return request({
    url: '/business/business/update',
    method: 'post',
    data: data
  })
}

// 查询列表
export function confirmeList(query){
  return request({
    url: '/business/business/confirmeList',
    method: 'get',
    params: query
  })
}
// 查询列表
export function getUserDept(){
  console.log('5555555555555555')
  return request({
    url: '/business/business/getUserDept',
    method: 'get'
  })
}
// 查询列表
export function list(query){
  return request({
    url: '/business/business/list',
    method: 'get',
    params: query
  })
}
//获取待填写的方法
export function getPendingList(){
  return request({
    url: '/wechat/getPendingList',
    method: 'get',
  })
}

// 新增受检单位
export function addInspectedUnit(data) {
  return request({
    url: '/wechat/addInspectedUnit',
    method: 'post',
    data: data
  })
}

// 查询列表
export function examineList(query){
  return request({
    url: '/business/business/examinelist',
    method: 'get',
    params: query
  })
}

// 修改定时任务调度
export function updateJob(data) {
  return request({
    url: '/monitor/job',
    method: 'put',
    data: data
  })
}

// 删除定时任务调度
export function delJob(jobId) {
  return request({
    url: '/monitor/job/' + jobId,
    method: 'delete'
  })
}

// 任务状态修改
export function changeJobStatus(jobId, status) {
  const data = {
    jobId,
    status
  }
  return request({
    url: '/monitor/job/changeStatus',
    method: 'put',
    data: data
  })
}


// 定时任务立即执行一次
export function runJob(jobId, jobGroup) {
  const data = {
    jobId,
    jobGroup
  }
  return request({
    url: '/monitor/job/run',
    method: 'put',
    data: data
  })}
